# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libilbc
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.2
pkgrel=1
pkgdesc="A friendly copy of the iLBC codec from the WebRTC project (mingw-w64)"
arch=('any')
license=('custom')
url="https://github.com/TimothyGu/libilbc/"
source=("${_realname}-${pkgver}.tar.bz2"::"https://github.com/TimothyGu/libilbc/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.bz2")
sha256sums=('88e2dc14e1fccd7b7a0d7f84e96ac22a33c3c86820cee4b0a05e3dcc08c2b096')

build() {
  cd "$srcdir"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
